<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仓库管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* 顶部导航栏容器 */
        .header-container {
            height: 60px;
            background: #2c3e50;
            color: white;
            flex-shrink: 0;
        }

        /* 主体内容容器 */
        .main-container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        /* 左侧导航栏容器 */
        .sidebar-container {
            width: 220px;
            background: #34495e;
            color: white;
            overflow-y: auto;
            transition: all 0.3s;
        }

        /* 内容区域容器 */
        .content-container {
            flex: 1;
            overflow-y: auto;
            background: #ecf0f1;
        }

        /* iframe样式 */
        .frame {
            width: 100%;
            height: 100%;
            border: none;
            display: block;
        }

        /* 响应式设计 - 移动端 */
        @media (max-width: 768px) {
            .sidebar-container {
                position: absolute;
                left: 0;
                top: 60px;
                bottom: 0;
                z-index: 100;
                transform: translateX(-100%);
            }

            .sidebar-container.show {
                transform: translateX(0);
            }

            .sidebar-overlay {
                position: absolute;
                top: 60px;
                left: 0;
                right: 0;
                bottom: 0;
                background: rgba(0,0,0,0.5);
                z-index: 99;
                display: none;
            }

            .sidebar-overlay.show {
                display: block;
            }
        }
    </style>
</head>
<body>
<!-- 顶部导航栏 -->
<div class="header-container">
    <iframe src="pages/top.html" class="frame" id="topFrame"></iframe>
</div>

<!-- 主体内容 -->
<div class="main-container">
    <!-- 左侧导航栏 -->
    <div class="sidebar-container" id="sidebar">
        <iframe src="pages/left.html" class="frame" id="leftFrame"></iframe>
    </div>

    <!-- 内容区域 -->
    <div class="content-container">
        <iframe src="pages/main.html" class="frame" name="content" id="contentFrame"></iframe>
    </div>

    <!-- 移动端侧边栏遮罩 -->
    <div class="sidebar-overlay" id="sidebarOverlay"></div>
</div>

<script>
    // 处理iframe通信
    window.addEventListener('message', function(event) {
        // 切换侧边栏显示/隐藏
        if (event.data.type === 'toggleSidebar') {
            const sidebar = document.getElementById('sidebar');
            const overlay = document.getElementById('sidebarOverlay');

            if (window.innerWidth <= 768) {
                sidebar.classList.toggle('show');
                overlay.classList.toggle('show');
            }
        }

        // 激活侧边栏菜单项
        if (event.data.type === 'activateMenuItem') {
            const leftFrame = document.getElementById('leftFrame');
            if (leftFrame && leftFrame.contentWindow) {
                leftFrame.contentWindow.postMessage({
                    type: 'setActiveItem',
                    itemId: event.data.itemId
                }, '*');
            }
        }
    });

    // 点击遮罩层关闭侧边栏
    document.getElementById('sidebarOverlay').addEventListener('click', function() {
        this.classList.remove('show');
        document.getElementById('sidebar').classList.remove('show');
    });

    // 响应式调整
    window.addEventListener('resize', function() {
        if (window.innerWidth > 768) {
            document.getElementById('sidebar').classList.remove('show');
            document.getElementById('sidebarOverlay').classList.remove('show');
        }
    });
</script>
</body>
</html>